#!/bin/bash

set -x

#if first argument is the empty string, generate all sorting types to standard location
#otherwise, generate sortingtypes to temp. 
if [ -z $1 ]
then  stlist="0 4 6 7 8 9 10"
      currdir=goodstats
      set -o noclobber
else  stlist="$1 $2 $3 $4 $5 $6 $7 $8 $9"
      currdir=temp
fi

imgname=../images/lenna.pgm


for sttype in $stlist
do
    echo "generating stats for sorting type $sttype"
    contextencode -ct 6 -cf goodcc/lennagtw.ctd -e 0 -s $sttype  $imgname temp/temp.bits
    contextdecode -bp 15 -bs 1 -cf goodcc/lennagtw.ctd -i $imgname temp/temp.bits temp/temp.pgm > $currdir/lennagtws${sttype}statsbs.txt
    contextdecode -bp 15 -bs 10000 -cf goodcc/lennagtw.ctd -i $imgname temp/temp.bits temp/temp.pgm > $currdir/lennagtws${sttype}stats.txt

done

